package com.landimc.sms.config;

import cn.hutool.bloomfilter.BitMapBloomFilter;
import cn.hutool.cache.Cache;
import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.TimedCache;
import com.landimc.sms.entity.Logs;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 配置TimeCache
 *
 * @author Yang
 * @version 1.0
 * @date 2020/10/26 14:34
 */
@Configuration
public class TimedCacheConfig {

    /**
     * 记录失败号码
     *
     * @return
     */
    @Bean
    public TimedCache<Long, AtomicInteger> timedCache() {
        TimedCache<Long, AtomicInteger> timedCache = CacheUtil.newTimedCache(1 * 60000 * 10);
        //启动定时任务，每10分钟检查一次过期
        timedCache.schedulePrune(1 * 60000 * 10);
        return timedCache;
    }

    /**
     * 记录操作日志
     *
     * @return
     */
    @Bean
    public TimedCache<String, Logs> timedLogsCache() {
        TimedCache<String, Logs> timedCache = CacheUtil.newTimedCache(1 * 60000 * 720);
        //启动定时任务，每12小时检查一次过期
        timedCache.schedulePrune(1 * 60000 * 720);
        return timedCache;
    }

}
